<?php  
    /**局部缓存**/
    $file = __TYPECHO_ROOT_DIR__ .'/usr/uploads/cache/y2_stat.php';     //缓存文件
    $period = 24 * 3600;         //缓存时间 1天
    if(!file_exists($file) || time() - filemtime($file) > $period){
         //初始化数据库
        $this->db = Typecho_Db::get(); 
                
        //标签数目
        $tagsnum=$this->db->fetchObject($this->db->select(array('COUNT(mid)' => 'num'))->from('table.metas')->where('table.metas.type = ?', 'tag'))->num;
                    
        //链接总数
        try{
            $linksnum = $this->db->fetchObject($this->db->select(array('COUNT(lid)' => 'num'))->from('table.links'))->num;
        }catch(Exception $e){
            $linksnum = 0;
        }

                    
        //最后更新
        $last=$this->db->fetchObject($this->db->select(array('MAX(modified)' => 'modified'))
                        ->from('table.contents')
            ->where('table.contents.type = ?','post'))->modified;
                        
        //日志总数
        $stat = Typecho_Widget::widget('Widget_Stat') ;
        $postnum = $stat->PublishedPostsNum;
                
        //评论总数
        $stat = Typecho_Widget::widget('Widget_Stat') ;
        $commnum = $stat->publishedCommentsNum;
                
               
        $statistics['tagsnum'] = $tagsnum ;
        $statistics['linksnum'] = $linksnum;
        $statistics['last'] = $last;
        $statistics['postnum'] = $postnum;
        $statistics['commnum'] = $commnum;
        SaveCache($file,serialize($statistics));    //写入缓存
    }else{
        $statistics = unserialize(LoadCache($file)); //从缓存中读出
        $postnum = $statistics['postnum'];
        $commnum = $statistics['commnum'];
        $tagsnum = $statistics['tagsnum'];
        $linksnum = $statistics['linksnum'];        
        $last = $statistics['last'];

    }
       
?>
<li><span>日志：<?php echo $postnum?>篇</span><span>评论：<?php echo $commnum;?>篇</span></li>
<li><span>标签：<?php echo $tagsnum?>个</span><span>链接：<?php echo $linksnum?>个</span></li>
<li>运行天数：<?php echo floor((time()-strtotime("2008/08/13"))/86400); ?>天</li>
<li>建站日期：2008年08月13日</li>
<li>最后更新：<?php echo date('Y年m月j日',$last);?></li>
